package com.kolakcc.loljclient.model;

import java.util.ArrayList;

import com.gvaneyck.rtmp.TypedObject;

public class CustomGameListItem {
	public TypedObject internalTypedObject;
	public String Name;
	public String gameMode;
	public int ID;
	public String allowSpectators;
	public int spectatorCount;
	public int gameMapID;
	public int maxPlayers;
	public CustomGamePlayer Owner;
	public boolean privateGame;
	public ArrayList<CustomGamePlayer> team1;
	public int team1Count;
	public ArrayList<CustomGamePlayer> team2;
	public int team2Count;

	// No clue what all of this is
	public String gameModeString; // seems to be the same as gameMode
	public Object glmGameID;
	public Object glmHost;
	public Object glmPort;
	public Object glmSecurePort;

	public CustomGameListItem(TypedObject data) {
		this.internalTypedObject = data;
		this.spectatorCount = data.getInt("spectatorCount");
		this.glmGameID = data.get("glmGameId");
		this.glmHost = data.get("glmHost");
		this.glmPort = data.get("glmPort");
		this.gameModeString = data.getString("gameModeString");
		this.allowSpectators = data.getString("allowSpectators");
		this.gameMapID = data.getInt("gameMapId");
		this.maxPlayers = data.getInt("maxNumPlayers");
		this.glmSecurePort = data.getInt("glmSecurePort");
		this.gameMode = data.getString("gameMode");
		this.ID = data.getInt("id");
		this.privateGame = data.getBool("privateGame");
		this.team1Count = data.getInt("team1Count");
		this.team2Count = data.getInt("team2Count");
		this.Owner = new CustomGamePlayer(data.getTO("owner"));
		this.Name = data.getString("name");
	}

	public boolean allowsSpectators() {
		return (this.allowSpectators.equals("ALL"));
	}

	@Override
	public String toString() {
		return "CustomGame [internalTypedObject=" + this.internalTypedObject
				+ ", Name=" + this.Name + ", gameMode=" + this.gameMode
				+ ", ID=" + this.ID + ", allowSpectators="
				+ this.allowSpectators + ", spectatorCount="
				+ this.spectatorCount + ", gameMapID=" + this.gameMapID
				+ ", maxPlayers=" + this.maxPlayers + ", Owner=" + this.Owner
				+ ", privateGame=" + this.privateGame + ", team1Count="
				+ this.team1Count + ", team2Count=" + this.team2Count
				+ ", gameModeString=" + this.gameModeString + ", glmGameID="
				+ this.glmGameID + ", glmHost=" + this.glmHost + ", glmPort="
				+ this.glmPort + ", glmSecurePort=" + this.glmSecurePort + "]";
	}
}
